﻿@{
    ViewBag.Title = "Add";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model YTCMS.Domain.Entities.ads

<script charset="utf-8" src="/Content/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/Content/kindeditor/lang/zh_CN.js"></script>
<div class="page-header">
    <h1>
        <a href="/ads/index"> 广告管理</a>
        <small>
            <i class="icon-double-angle-right"></i> 修改广告
        </small>
    </h1>
</div><!-- /.page-header -->

<div class="row">
    <div class="col-xs-12">
        <div class="row">
            <div class="col-xs-12 ">

            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <form class="form-horizontal" role="form" id="form1" method="post" action="/ads/edit">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 标题 </label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Title, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> Code （注：code 不可以随意更改）</label>
                        <div class="col-sm-9">
                            @Html.TextBoxFor(s => s.Code, new { @class = "col-xs-10 col-sm-5 required" })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 备注 </label>
                        <div class="col-sm-9">
                            @Html.TextAreaFor(s => s.Remark, new { @class = "col-xs-10 col-sm-5 ", cols = "20", rows = "4", style = "margin: 0px; width: 767px; height: 76px;", @maxlength = 500 })
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="password-input">状态</label>
                        <div class="col-md-9">
                            @Html.DropDownListFor(s => s.State, Admin.Common.YTDDL.CommonState(true, Model.State.ToString()), new { @class = "form-control" })
                        </div>
                    </div>
                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="button" id="btnSave">
                                <i class="icon-ok bigger-110"></i>
                                新增
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="icon-undo bigger-110"></i>
                                撤销
                            </button>
                        </div>
                    </div>
                    @Html.HiddenFor(s=>s.Id)
                    @Html.HiddenFor(s => s.CreateTime)
                </form>
            </div><!-- /span -->
        </div><!-- /row -->
    </div><!-- /.col -->
</div><!-- /.row -->

<script type="text/javascript">
    $(function () {
        $("#btnSave").click(function () {
            var b = jQuery("#form1").valid();
            if (b) {
                $.post("/ads/edit", $("#form1").serialize(), function (data) {
                    if (data.d) {
                        jAlert("修改成功", "提示", function () {
                            location.href = "/ads/index";
                        })
                    }
                    else {
                        jAlert(data.msg, "提示");
                    }
                })
            }
        });

        var editor;
        KindEditor.ready(function (K) {
            editor = K.create('textarea[name="Remark"]', {
                uploadJson: '/Util/KindEditorHandlerFile',
                afterBlur: function () { editor.sync(); },
                allowFileManager: true
            });
        });
    })
</script>